﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Core;

namespace DAL
{
    public class RePutQuestionDetailDAL : SyncBase<Model.RePutQuestionDetail>
    {
        static RePutQuestionDetailDAL()
        {
            StringBuilder strSql = new StringBuilder();
            RePutQuestionDetailDAL.addSQL = @"insert into TempRePutQuestionDetail(
QuestionID,StudentID,IsWin,AnswerTime,AnswerPiont,AnswerEffect,RecordTime)
 values (
@QuestionID,@StudentID,@IsWin,@AnswerTime,@AnswerPiont,@AnswerEffect,@RecordTime)";
            RePutQuestionDetailDAL.tbName = "TempRePutQuestionDetail";
            RePutQuestionDetailDAL.remoteUrl = "/Ayyfford/AddRePutQuestionDetail";
            RePutQuestionDetailDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0}, {1}, {2},{3}, {4}, {5}, {6}),",
                            t.QuestionID.NullNumber(), t.StudentID.NullNumber(), t.IsWin ? 1 : 0, t.AnswerTime.NullDate(), t.AnswerPiont.NullNumber(), t.AnswerEffect.NullString(), t.RecordTime.NullDate());
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.RePutQuestionDetail t)
        {
            SyncBase<Model.RePutQuestionDetail>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.RePutQuestionDetail>.AsyncData();
        }
    }
}
